<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
      <!-- <el-form-item label="检测开始日期" prop="checkStartDate">
        <el-date-picker
          clearable
          v-model="queryParams.checkStartDate"
          type="date"
          value-format="yyyy-MM-dd 00:00:00"
          placeholder="请选择开始日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="检测结束日期" prop="checkEndDate">
        <el-date-picker
          clearable
          v-model="queryParams.checkEndDate"
          type="date"
          value-format="yyyy-MM-dd 23:59:59"
          placeholder="请选择结束日期"
        ></el-date-picker>
      </el-form-item>-->
      <el-form-item label="检验单编号" prop="oqcCode">
        <el-input v-model="queryParams.oqcCode" placeholder="请输入检验单编号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="发货单据编号" prop="fbillno">
        <el-input v-model="queryParams.fbillno" placeholder="请输入发货单据编号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="客户名称" prop="clientName">
        <el-input v-model="queryParams.clientName" placeholder="请输入客户名称" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="出货日期" prop="outDate">
        <el-date-picker clearable v-model="queryParams.outDate" type="date" value-format="yyyy-MM-dd 00:00:00"
          placeholder="请选择出货日期"></el-date-picker>
      </el-form-item>
      <el-form-item label="质检状态" prop="qualityStatus">
        <el-select v-model="queryParams.qualityStatus" placeholder="请选择质检状态" clearable>
          <el-option label="未质检" :value="0" />
          <el-option label="质检中" :value="1" />
          <el-option label="已质检" :value="2" />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="qcindexList" height="calc(100vh - 314px)">
      <el-table-column label="序号" align="center" width="50px" prop="issueCode">
        <template slot-scope="scope">
          <span>{{ scope.$index + 1 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="检验单编号" align="center" width="160" prop="oqcCode">
        <template slot-scope="scope">
          <el-button size="mini" type="text" @click="handleView(scope.row)">{{ scope.row.oqcCode }}</el-button>
        </template>
      </el-table-column>
      <!-- <el-table-column label="检验单名称" align="center" prop="oqcName"></el-table-column> -->
      <el-table-column label="发货单据编号" align="center" prop="fbillno"></el-table-column>
      <el-table-column label="客户名称" align="center" prop="clientName"></el-table-column>
      <el-table-column label="出货日期" align="center" prop="outDate"></el-table-column>
      <el-table-column label="质检状态" align="center" prop="qualityStatus">
        <template slot-scope="scope">{{ scope.row.qualityStatus == '0' ? "未质检" : scope.row.qualityStatus
          == '1' ? "质检中" : scope.row.qualityStatus == '2' ? "已质检" : '--' }}</template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />
    <Details ref="details"></Details>
  </div>
</template>

<script>
import oqcDetail from "./oqc_detail.vue";
import Details from "./indexA.vue";
import {
  listInspection,
  getInspection,
  delInspection,
  addInspection,
  updateInspection,
  templateindexList,
  getabnormalList,
  listOQC
} from "@/api/mes/qc/qcOqcInspection";
import { genCode } from "@/api/mes/md/rule";
export default {
  name: "Fqc",
  dicts: ["mes_index_type"],
  components: { oqcDetail, Details },
  data() {
    return {
      //自动生成编码
      autoGenFlag: false,
      optType: undefined,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 检测项表格数据
      qcindexList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        oqcCode: null,
        indexName: null,
        indexType: null,
        qcTool: null
      },
      // 表单参数
      form: {},
      // sncode集合
      snObj: {},
      radioObj: {},
      // 表单校验
      rules: {
        snCode: [{ required: true, message: "SN码不能为空", trigger: "blur" }],
        checkResult: [
          { required: true, message: "检验结果不能为空", trigger: "change" }
        ],
        headEndCheckType: [
          { required: true, message: "类型不能为空", trigger: "change" }
        ]
      },
      indexCodeDisabled: false,
      // 模板列表
      templateList: [],
      loading1: false,
      spanArr: [],
      // 异常记录列表
      errorList: [],
      // 不合格数
      failedSncode: [],
      // 首页列表信息
      QcFqcAcInspectionHead: {},
      //模块id
      templateId: "",
      //异常列表
      abnormalList: [],
      //详情页面
      detailVisible: false
    };
  },
  created() {
    this.getList();
  },

  methods: {
    /** 查询检测项列表 */
    getList() {
      this.loading = true;
      listOQC(this.queryParams).then(response => {
        console.log(response, "tableres");
        this.qcindexList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        checkResult: null,
        snCode: null,
        indexName: null,
        indexType: null,
        headEndCheckType: null,
        remark: null
      };
      this.snObj = {};
      this.radioObj = {};
      this.templateList = [];
      this.autoGenFlag = false;
      this.loading1 = false;
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      console.log(this.queryParams, "=====queryParams===");
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    handleView(row) {
      this.$nextTick(() => {
        this.$refs.details.init(row);
      });
    }
  }
};
</script>
<style scoped>
.tableItem .el-form-item__content {
  margin-left: 0px !important;
}

.tableItem ::v-deep .el-form-item__content {
  margin-left: 0px !important;
}

.headerDiv {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dialogContent ::v-deep .el-upload--picture-card {
  width: 80px;
  height: 80px;
  line-height: 80px;
}

.dialogContent .el-table {
  font-size: 12px;
}

ul li {
  list-style: none;
}

.mInput {
  display: flex;
  align-items: center;
  margin-bottom: 5px;
}

.el-icon-circle-plus-outline {
  font-size: 16px;
}

.el-icon-remove-outline {
  font-size: 16px;
}
</style>
